package 第一章基础算法.双指针.id800数组元素的目标和;

import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int[] A = new int[n];
        int[] B = new int[m];
        for(int i = 0;i<n;i++){
            A[i] = scanner.nextInt();
        }
        for(int i = 0;i<m;i++){
            B[i] = scanner.nextInt();
        }
        //双指针
        int p1 = 0;
        int p2 = m-1;
        while (p1 < n && p2 > 0){
            int cur = A[p1] + B[p2];
            if(cur > x){
                p2--;
            }else if(cur < x){
                p1++;
            }else {
                System.out.println(p1 + " " + p2);
                break;
            }
        }
    }
}
